#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

int main()
{
	int price = 0;
	scanf("%d", &price);
	int pop = 1;
	int ret = 0;
	ret = price / pop;
	int sum = ret;
	while (ret != 2)
	{
		ret = ret / 2;
		sum = sum + ret;
	}
	
	printf("%d\n", sum);
	return 0;
}